package course.mycollection;

import java.util.ArrayList;
import java.util.Iterator;

public class Demo8 {
    public static void main(String[] args) {
        ArrayList<Student> list = new ArrayList<>();

        Student s1 = new Student("小皮同学",23);
        Student s2 = new Student("小路同学",21);
        Student s3 = new Student("小贾同学",33);

        list.add(s1);
        list.add(s2);
        list.add(s3);

        Iterator<Student> it = list.iterator();
        while (it.hasNext()){
            System.out.println(it.next());
        }

        System.out.println("-----------------------");

        for (Student student : list) {
            System.out.println(student);
        }

    }
}
